<?php if(!class_exists('raintpl')){exit;}?><?php $tpl = new RainTPL;$tpl_dir_temp = self::$tpl_dir;$tpl->assign( $this->var );$tpl->draw( dirname("header") . ( substr("header",-1,1) != "/" ? "/" : "" ) . basename("header") );?>
<?php $tpl = new RainTPL;$tpl_dir_temp = self::$tpl_dir;$tpl->assign( $this->var );$tpl->draw( dirname("navigator") . ( substr("navigator",-1,1) != "/" ? "/" : "" ) . basename("navigator") );?>

<div id = "container">
	<h1 class = "header">ข้อมูลพื้นฐาน (Common Data Set)</h1>
	<br>

	<?php if( $user['level_name']=='officer' ){ ?>
		<div class = "tool">
			<a href = "common-form.php"><img src="http://localhost/kpi/html/images/icon/add.png">เพิ่มข้อมูลพื้นฐาน</a>
		</div>

		<?php $counter1=-1; if( isset($group) && is_array($group) && sizeof($group) ) foreach( $group as $key1 => $value1 ){ $counter1++; ?>
		<table cellpadding = "0" cellspacing = "0" border = "0" class = "list">
			<tr>
				<th class = 'w600'><?php echo $value1["name"];?></th>
				<th class = 'w80'>จำนวน</th>
				<th class = 'w70'>เครื่องมือ</th>
			</tr>
			<?php $counter2=-1; if( isset($data[$value1["id"]]) && is_array($data[$value1["id"]]) && sizeof($data[$value1["id"]]) ) foreach( $data[$value1["id"]] as $key2 => $value2 ){ $counter2++; ?>
				<?php if( $value2["gid"] == $value1["id"] ){ ?>
				<tr class = "alt<?php echo $key2%2;?>">
					<td>
						<a href = "common-edit.php?id=<?php echo $value2["id"];?>"><?php echo $key2+1;?>. <?php echo $value2["name"];?></a>
						<?php if( $value2["upload"]!='' ){ ?>
						<a href = "<?php echo $value2["upload"];?>" target = "_blank"><img src="http://localhost/kpi/html/images/filetype_icons/<?php echo $value2["icon"];?>" class = "icon"></a>
						<?php } ?>
					</td>
					<td><?php echo $value2["target"];?></td>
					<td>
						<a href = "common-edit.php?id=<?php echo $value2["id"];?>" alt = "แก้ไข" title = "แก้ไข"><img src="http://localhost/kpi/html/images/icon/edit.png"></a>
						<a href = "common-delete.php?id=<?php echo $value2["id"];?>" alt = "ลบ" title = "ลบ" class = "delete"><img src="http://localhost/kpi/html/images/icon/delete.png"></a>
					</td>
				</tr>
				<?php } ?>
			<?php } ?>
		</table>
		<?php } ?>

	<?php }else{ ?>

		<?php $counter1=-1; if( isset($group) && is_array($group) && sizeof($group) ) foreach( $group as $key1 => $value1 ){ $counter1++; ?>
		<table cellpadding = "0" cellspacing = "0" border = "0" class = "list">
			<tr>
				<th class = 'w600'><?php echo $value1["name"];?></th>
				<th class = 'w80'>จำนวน</th>
			</tr>
			<?php $counter2=-1; if( isset($data[$value1["id"]]) && is_array($data[$value1["id"]]) && sizeof($data[$value1["id"]]) ) foreach( $data[$value1["id"]] as $key2 => $value2 ){ $counter2++; ?>
				<?php if( $value2["gid"] == $value1["id"] ){ ?>
				<tr class = "alt<?php echo $key2%2;?>">
					<td>
						<?php echo $key2+1;?>. <?php echo $value2["name"];?>
						<?php if( $value2["upload"]!='' ){ ?>
						<a href = "<?php echo $value2["upload"];?>" target = "_blank"><img src="http://localhost/kpi/html/images/filetype_icons/<?php echo $value2["icon"];?>" class = "icon"></a>
						<?php } ?>
					</td>
					<td><?php echo $value2["target"];?></td>
				</tr>
				<?php } ?>
			<?php } ?>
		</table>
		<?php } ?>

	<?php } ?>
</div>
<?php $tpl = new RainTPL;$tpl_dir_temp = self::$tpl_dir;$tpl->assign( $this->var );$tpl->draw( dirname("footer") . ( substr("footer",-1,1) != "/" ? "/" : "" ) . basename("footer") );?>